package com.huichaoliu.stylist.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;

import com.huichaoliu.app.R;
import com.rederxu.farmer.BaseActivity;

public class LoginStylistActivity extends BaseActivity implements
		OnClickListener {
	// View
	TextView login_stylist;
	TextView login_login;
	EditText login_name;
	EditText login_password;

	// tools
	Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_login_stylist);
		super.onCreate(savedInstanceState);
		context = LoginStylistActivity.this;
	}

	@Override
	public void init() {
		login_stylist = (TextView) findViewById(R.id.login_stylist);
		login_login = (TextView) findViewById(R.id.login_login);
		login_name = (EditText) findViewById(R.id.login_name);
		login_password = (EditText) findViewById(R.id.login_password);

		login_stylist.setOnClickListener(this);
		login_login.setOnTouchListener(new OnTouchListener() {

			@SuppressLint("ClickableViewAccessibility")
			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {
				int x = (int) arg0.getX();
				int y = (int) arg0.getY();
				switch (arg1.getAction()) {
				case MotionEvent.ACTION_DOWN:
					arg0.setX(x - 10);
					arg0.setY(y + 10);
					break;
				case MotionEvent.ACTION_MOVE:
					break;
				case MotionEvent.ACTION_UP:
					arg0.setY(y - 10);
					arg0.setX(x + 10);
					doLogin();
					break;
				default:
					break;
				}
				return true;
			}
		});
	}

	@Override
	public void initData() {

	}

	@Override
	public void onNetworkChanged(boolean isMobNetConnected,
			boolean isWifiConnected) {
		// TODO Auto-generated method stub

	}

	private void doLogin() {
		// String name = login_name.getText().toString();
		// String passWord = login_password.getText().toString();

		// if (name == null || "".equals(name)) {
		// Toast.makeText(context, "请输入账号", Toast.LENGTH_LONG).show();
		// return;
		// }
		//
		// if (passWord == null || "".equals(passWord)) {
		// Toast.makeText(context, "请输入密码", Toast.LENGTH_LONG).show();
		// return;
		// }

		mHandler.sendEmptyMessage(1);

	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		// 跳转网页 怎么成为设计师
		case R.id.login_stylist:
			Intent intent = new Intent(context, StylistToBeActivity.class);
			// Intent intent = new Intent(context,
			// StylistShoppingActivity.class);
			startActivity(intent);
			break;

		default:
			break;
		}
	}

	@SuppressLint("HandlerLeak")
	Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				Intent intent = new Intent(context, StylistMainActivity.class);
				startActivity(intent);
				break;

			default:
				break;
			}
		}
	};

}
